﻿<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">汇报列表</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">汇报管理</a>
                </li>
                <li class="breadcrumb-item active">汇报列表</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <h4 class="example-title">汇报信息</h4>
                    <div class="row">
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">发送人</label>
                            <input type="text" class="form-control" id="ipt_fasongren" name="" placeholder="请输入发送人" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">接收人</label>
                            <input type="text" class="form-control" id="ipt_jieshouren" name="" placeholder="请输入接收人" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="control-label" for="inputBasicPassword">汇报类型</label>
                            <select class="form-control" id="slt_HuiBaoLeiXing" name="" data-fv-notempty="true" data-fv-field="requiredSelect">
                                <option value="0" selected="selected">请选择</option>
                                <option value="日报">日报</option>
                                <option value="周报">周报</option>
                                <option value="月报">月报</option>
                            </select>
                        </div>
                        <div class="form-group col-sm-12 row" style="text-align: center;padding-top:28px">
                            <div class="col-sm-6">
                                <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 100%; float: left;" onclick="ChaXun()"><i class="icon wb-search"></i>查询</button>
                            </div>
                            <div class="col-sm-6">
                                <button type="button" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 100%;" onclick="ChongZhi();">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                        <thead>
                            <tr>
                                <th>编号</th>
                                <th>发送人</th>
                                <th>接收人</th>
                                <th>汇报类型</th>
                                <th>汇报时间</th>
                                <th>汇报状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#SpanHuiBao").click();
        huibao("","","");
    });

    function huibao(fasongren, jieshouren, huibaoleixing) {
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[0, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                console.log(data);
                var param = {};
                param.sw = "";
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;

                param.fasongren = fasongren;
                param.jieshouren = jieshouren;
                param.huibaoleixing = huibaoleixing;

                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../HuiBao/GetHuiBaoListDate",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "Id" },
                { "data": "HuiBaoRenXinXi.XingMing" },
                { "data": "JieShouRenXinXi.XingMing" },
                { "data": "HuiBaoLeiXing" },
                { "data": "HuiBaoShiJian" },
                { "data": "HuiBaoZhuangTai" },
                { "data": null }
            ]
            ,
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    return '<button type="button" class="btn btn-outline btn-default" onclick="ydufangfa(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>查看</button>'
                }
            }]
        })
    };

    function ChaXun()
    {
        var fasongren = $("#ipt_fasongren").val();
        var jieshouren = $("#ipt_jieshouren").val();
        var huibaoleixing = $("#slt_HuiBaoLeiXing").find("option:selected").val();
        huibao(fasongren,jieshouren,huibaoleixing);
    }

    function ChongZhi()
    {
        $("#ipt_fasongren").val("");
        $("#ipt_jieshouren").val("");
        $("#slt_HuiBaoLeiXing").find("option").eq(0).prop("selected", true)
        huibao("", "", "");
    }

    function ydufangfa(id) {
        var huibaoid = id;
        $.ajax({
            type: 'post',
            url: '../HuiBao/GetHuiBaoLeiXing',
            async: false,
            dataType: 'text',
            data: { huibaoid: huibaoid },
            success: function (date) {
                if (date == "日报") {
                    location.href = "../HuiBao/PCRiBao?id=" + huibaoid + "&benren=1";
                } else if (date == "周报") {
                    location.href = "../HuiBao/PCZhouBao?id=" + huibaoid + "&benren=1";
                } else if (date == "月报") {
                    location.href = "../HuiBao/PCYueBao?id=" + huibaoid + "&benren=1";
                }
            },
        })
    }

</script>